﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DLTN.Entities;
using DLTN.Data;
using System.Data;

public partial class Controls_ControlGalleryContent : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Pager1.CurrentIndex = 1;
            Bind_Data(Pager1.CurrentIndex);
        }
    }
    protected void Bind_Data(int PageNo)
    {
        try
        {
            int TotalRows = 0;
            string WhereClause = "1=1";
            DataSet dsvideo = DataRepository.Provider.ExecuteDataSet("BoSuuTap_GetPaged", WhereClause, "Id DESC", PageNo - 1, Pager1.PageSize);
            dlBoSuuTap.DataSource = dsvideo.Tables[0];
            dlBoSuuTap.DataBind();
            try
            {
                TotalRows = Convert.ToInt32(dsvideo.Tables[1].Rows[0][0]);
            }
            catch (Exception)
            {
            }
            Pager1.ItemCount = TotalRows;
            if (TotalRows <= Pager1.PageSize)
                Pager1.Visible = false;
            else
                Pager1.Visible = true;
        }
        catch (Exception)
        {
        }
    }

    protected void Pager1_Command(object sender, CommandEventArgs e)
    {
        int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
        Pager1.CurrentIndex = currnetPageIndex;
        Bind_Data(currnetPageIndex);
    }

    public string GetDienGiai(object Char)
    {
        int i = Convert.ToInt32(Char.ToString());
        TList<HinhAnh> TList_HinhAnh = DataRepository.HinhAnhProvider.Find("IdBoSuuTap=" + i);
        if (TList_HinhAnh.Count > 0)
            return TList_HinhAnh[0].DienGiai;
        else return "";
    }

    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}